#include "model.h"
#include <QColor>
#include <QPainter>
#include <QPen>
#include <math.h>
#include <QHBoxLayout>
#include <QVector>
#include <client.h>
#include <QHostAddress>
#include <QTcpSocket>
#include <QtDebug>
#include "stdio.h"

Model::Model(QWidget *parent) : QWidget(parent)
{
    //tcpSocket = new QTcpSocket(this);



}

/*void Model::setValue(){
    connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readMessage()));


    this->repaint();


}*/

/*void Model::readMessage(){
    printf("1");
    QByteArray array = tcpSocket->readAll();
    double ss = QVariant(array).toDouble();
    theta = ss;
}*/
/*
void Model::paintEvent(QPaintEvent *event){




    Q_UNUSED(event);

    QPainter painter(this);
    painter.begin(this);

    QSize size = this->size();
    int Qwidth = size.width();
    int Qheight = size.height();

    int x_posi = int((((Qwidth-80) / this->MAX_VIEW) * this->position));
    int y_posi = Qheight - this->stick_length;
    int rotate_center[2] = {int(x_posi+this->car_size[0]/2), y_posi};



    if (this->position <= this->MAX_VIEW){
        QPen pen;

        pen.setWidth(15);
        pen.setColor(QColor(0,0,179));
        painter.setPen(pen);
        int end_point_x = rotate_center[0] - int(this->stick_length * sin(-this->theta));
        int end_point_y = rotate_center[1] - int(this->stick_length * cos(-this->theta));
        painter.drawLine(rotate_center[0], rotate_center[1], end_point_x, end_point_y);

        pen.setWidth(2);
        pen.setColor(QColor(255, 255, 255));
        painter.setPen(pen);
        painter.setBrush(QColor(255, 255, 184));
        painter.drawRect(x_posi, y_posi, this->car_size[0], this->car_size[1]);




    }
    painter.end();
}
*/

